package com.thevenin.utils;

import java.math.BigDecimal;
import java.math.BigInteger;

public class BitRateCalculatorFonc {
	
	public static  Integer calculBitrate(Integer desiredMoSize, Integer durationHours, Integer durationMinutes, Integer durationSeconds, Integer audioBitRateInKbps) {
		// VideoKbps = ((desiredMoSize*8388608) - (1024*duration*audioBitRateInKbps))/(1024*duration);

		Integer duration = (((durationHours * 60) + durationMinutes) * 60) + durationSeconds;
		BigInteger val1 = BigInteger.valueOf(desiredMoSize).
		  multiply(BigInteger.valueOf(8388608)).
		  subtract(BigInteger.valueOf(1024).
				  multiply(BigInteger.valueOf(duration)).
				  multiply(BigInteger.valueOf(audioBitRateInKbps))).
		  divide(BigInteger.valueOf(1024).multiply(BigInteger.valueOf(duration)));
		return val1.intValue();
		
	}
	
}
